package common

import (
	"runtime"
	"strings"
	"time"
)

func NewValue[T any](value T) *T {
	v := new(T)
	*v = value
	return v
}

func CallerLatency(s time.Time) (string, time.Duration) {
	pc, _, _, _ := runtime.Caller(1)
	name := runtime.FuncForPC(pc).Name()
	split := strings.Split(name, ".")
	return split[len(split)-1], time.Now().Sub(s)
}
